package 数组.middle;

/**
 * @author Lw中
 * @date 2020/8/15 9:41
 */
public class YiSanSiSan {

    public static int numOfSubarrays(int[] arr, int k, int threshold) {
        int n = 0;
        // 总共有arr.length - k + 1个子数组
        for (int i = 0; i < arr.length - k + 1; i++) {
            int sum = 0;
            for (int j = i; j < i + k; j++) {
                sum += arr[j];
            }
            if (sum/k >= threshold) {
                n++;
            }
        }
        return n;
    }

    public static void main(String[] args) {
        int[] arr = {11,13,17,23,29,31,7,5,2,3};
        int i = numOfSubarrays(arr, 3, 5);
        System.out.println(i);
    }

}
